package com.example.by.mdb.fragment;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.example.by.mdb.activity.Login;
import com.example.by.mdb.activity.MainActivity;
import com.example.by.mdb.R;
import com.example.by.mdb.db.MyDatabaseHelper;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;

/**
 * Created by BY on 2016/1/5.
 */
public class QuitFragment extends Fragment implements View.OnClickListener {
    private View view;
    private LinearLayout changeUserLayout, quitLayout;
    private TextView workerName;
    private SQLiteDatabase db;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.quit_fragment, null);
        init();
        return view;
    }

    private void init() {
        MyDatabaseHelper myDatabaseHelper = new MyDatabaseHelper(getContext(), "pda.db");
        db = myDatabaseHelper.getReadableDatabase();
        MainActivity activity = (MainActivity) getActivity();
        workerName = (TextView) view.findViewById(R.id.workerName);
        workerName.setText(activity.workerName);
        changeUserLayout = (LinearLayout) view.findViewById(R.id.changeUser);
        quitLayout = (LinearLayout) view.findViewById(R.id.quit);
        changeUserLayout.setOnClickListener(this);
        quitLayout.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.changeUser:
                Intent intent = new Intent(getActivity(), Login.class);
                startActivity(intent);
                getActivity().finish();
                break;
            case R.id.quit:

                break;
        }
    }


}
